<template>
  <div>
    <Searchbar>
      <el-input @change="getList" v-model="search.studentid" placeholder="请输入用户学号、姓名"></el-input>
      <el-button class="search-btn" @click="getList" type="primary">查询</el-button>
    </Searchbar>

    <el-table :data="tableData" style="width: 100%">
      <el-table-column prop="username" label="用户姓名"></el-table-column>
      <el-table-column prop="start_time" label="考试时间"></el-table-column>
      <el-table-column prop="duration" label="考试耗时"></el-table-column>
      <el-table-column prop="score" label="成绩"></el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button @click="goJudge(scope.row)" size="small" class="text-button">评分</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      background
      layout="prev, pager, next, jumper"
      @current-change="handleCurrentChange"
      @size-change=handleSizeChange
      :current-page.sync="search.page"
      :page-size="search.page_size"
      :total="total"
    ></el-pagination>
  </div>
</template>
<script>
import pageMixin from "@/mixins/pageMixin";
import { paperModel } from "@/api/models";
import Searchbar from "@/components/Searchbar";
export default {
  mixins: [pageMixin],
  components: { Searchbar },
  props: {
    exam_id: null
  },
  data() {
    return {
      tableData: [],
      total: 0,
      search: {
        paper_name: null,
        course_name: null,
        studentid: null,
        student_name: null,
        exam_id: null,
        page: 1,
        page_size: 10,
      },
    };
  },
  mounted() {
    this.search.exam_id = this.exam_id
    this.getList();
  },
  methods: {
    getList() {
      console.log("getList");
      paperModel.list(
        this.search,
        (res) => {
          this.total = res.total_records;
          this.tableData = res.data.map((v) => {
            return v;
          });
        },
        (err) => {
          console.log(err);
        }
      );
    },
    goJudge(row) {
      this.$router.push('judge/paper/' + row.id)
      console.log(row)
    }
  }
};
</script>
<style lang="scss">
</style>